function [eqmin] = fractionatePlagioclase_V2(liquidComp,CaNaKD)
 D_TiO2 = 0.001;
 D_Cr2O3 = 0.001;
 D_K2O = 0.271;
 
 % Columns are Ti, Cr, K, Na
% Rows are cpx, opx, olv, plagioclase/spinel/garnet
 
% DMP = ...
%     [0.42	4.3       0.001	    0.15 
%     0.19	5         0.001	    0.04
%     0.03	1.45     0.001	   0.001
%     0.001   0.001	0.271	  1];



MW = [60.085 79.899	101.961	151.9902	71.846	70.9374	40.311	56.079	61.979	94.203	283.89]; 
%     1-SiO2    2-TiO2    3-Al2O3   4-Cr2O3       5-FeO     6-MnO     7-MgO     8-CaO    9-Na2O    10-K2O    11-P2O5
%      1        2               3          4             5          6          7           8         9

liquidComp_moles = liquidComp./MW;
liquidComp_moles = 100*liquidComp_moles/nansum(liquidComp_moles); %%normalizes the molar liquid composition, unneccessary step
XCa = liquidComp_moles(8)./(liquidComp_moles(8) + 2*liquidComp_moles(9));
VP = CaNaKD*XCa/(1-XCa);
XPL = VP./(1+VP);


    M_eqmin(1) = XPL*50+(1-XPL)*75;
    M_eqmin(2) = 0;
    M_eqmin(3) = XPL*25+(1-XPL)*12.5;
    M_eqmin(4) = 0;
    M_eqmin(5) = 0;
    M_eqmin(6) = 0;
    M_eqmin(7) = 0;
    M_eqmin(8) = 25*XPL;
    M_eqmin(9) = (1-XPL)*12.5;
    M_eqmin(10) = 0;
    M_eqmin(11) = 0;
    

    eqmin = M_eqmin.*MW;                % this is the bulk comosition of equilibrium olivine
    eqmin = eqmin./(0.01*nansum(eqmin));   % renormalized and in wt%
    

    eqmin(2) = D_TiO2.*liquidComp(2);
    eqmin(4) = D_Cr2O3.*liquidComp(4);
    eqmin(10) = D_K2O.*liquidComp(10);
    eqmin = eqmin./(0.01*nansum(eqmin));   % renormalized and in wt%
    

end

